package com.qd.common.sys.domain.entity.system;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.cdqidi.util.page.BaseQuery;
import com.cdqidi.valid.group.DefaultGroup;
import com.cdqidi.valid.group.DeleteGroup;
import com.cdqidi.valid.group.UpdateGroup;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.JsonNode;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;

/**
 * 系统设置
 *
 * @author sjk
 */
@EqualsAndHashCode(callSuper = true)
@Getter
@Setter
public class SystemSetDTO extends BaseQuery {

    @ExcelIgnore
    @JsonIgnore
    private static final String EXCEL_TITLE = "系统设置";
    /**
     * 主键
     */
    @ExcelProperty(value = {EXCEL_TITLE, "参数编码"})
    @NotBlank(message = "参数编码不能为空", groups = {DeleteGroup.class, UpdateGroup.class})
    @Size(max = 50, message = "参数编码长度不能超过{max}位", groups = {DeleteGroup.class, UpdateGroup.class})
    private String code;
    /**
     * 参数名称
     */
    @ExcelProperty(value = {EXCEL_TITLE, "参数名称"})
    @NotBlank(message = "参数名称不能为空", groups = DefaultGroup.class)
    @Size(max = 100, message = "参数名称长度不能超过{max}位", groups = DefaultGroup.class)
    private String name;
    /**
     * 值
     */
    @ExcelIgnore
    @NotNull(message = "值不能为空", groups = DefaultGroup.class)
    private JsonNode value;
    @ExcelProperty(value = {EXCEL_TITLE, "值"})
    @JsonIgnore
    private String valueDisplay;
    /**
     * 是否内置
     */
    @ExcelIgnore
    @NotNull(message = "是否内置不能为空", groups = DefaultGroup.class)
    private Integer type;
    /**
     * 是否内置显示
     */
    @ExcelProperty(value = {EXCEL_TITLE, "是否内置"})
    private String typeDisplay;
    /**
     * 备注
     */
    @ExcelProperty(value = {EXCEL_TITLE, "备注"})
    @NotBlank(message = "备注不能为空", groups = DefaultGroup.class)
    @Size(max = 300, message = "备注长度不能超过{max}位", groups = DefaultGroup.class)
    private String note;
    /**
     * 添加时间
     */
    @ExcelProperty(value = {EXCEL_TITLE, "添加时间"})
    private LocalDateTime addTime;
    /**
     * 更新时间
     */
    @ExcelProperty(value = {EXCEL_TITLE, "更新时间"})
    private LocalDateTime updateTime;

    @Override
    public void freeData() {
        this.code = null;
        this.name = null;
        this.value = null;
        this.valueDisplay = null;
        this.type = null;
        this.typeDisplay = null;
        this.note = null;
        this.addTime = null;
        this.updateTime = null;
        super.freeData();
    }
}
